package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.PrivacyPolicy;
import com.zjsd.sqeybusiness.service.IPrivacyPolicyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 精品汇隐私条款Controller
 *
 * @author Zheng
 * @date 2020-11-05
 */
@RestController
@RequestMapping("/jph/privacyPolicy")
public class PrivacyPolicyController extends BaseController
{
    @Autowired
    private IPrivacyPolicyService privacyPolicyService;

    /**
     * 查询精品汇隐私条款列表
     */
    @PreAuthorize("@ss.hasPermi('jph:privacyPolicy:list')")
    @GetMapping("/list")
    public TableDataInfo list(PrivacyPolicy privacyPolicy)
    {
        startPage();
        List<PrivacyPolicy> list = privacyPolicyService.selectPrivacyPolicyList(privacyPolicy);
        return getDataTable(list);
    }

    /**
     * 导出精品汇隐私条款列表
     */
    @PreAuthorize("@ss.hasPermi('jph:privacyPolicy:export')")
    //@Log(title = "精品汇隐私条款", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PrivacyPolicy privacyPolicy)
    {
        List<PrivacyPolicy> list = privacyPolicyService.selectPrivacyPolicyList(privacyPolicy);
        ExcelUtil<PrivacyPolicy> util = new ExcelUtil<PrivacyPolicy>(PrivacyPolicy.class);
        return util.exportExcel(list, "privacyPolicy");
    }

    /**
     * 获取精品汇隐私条款详细信息
     */
    @PreAuthorize("@ss.hasPermi('jph:privacyPolicy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(privacyPolicyService.selectPrivacyPolicyById(id));
    }

    /**
     * 新增精品汇隐私条款
     */
    @PreAuthorize("@ss.hasPermi('jph:privacyPolicy:add')")
    //@Log(title = "精品汇隐私条款", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PrivacyPolicy privacyPolicy)
    {
        return toAjax(privacyPolicyService.insertPrivacyPolicy(privacyPolicy));
    }

    /**
     * 修改精品汇隐私条款
     */
    @PreAuthorize("@ss.hasPermi('jph:privacyPolicy:edit')")
    //@Log(title = "精品汇隐私条款", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PrivacyPolicy privacyPolicy)
    {
        return toAjax(privacyPolicyService.updatePrivacyPolicy(privacyPolicy));
    }

    /**
     * 删除精品汇隐私条款
     */
    @PreAuthorize("@ss.hasPermi('jph:privacyPolicy:remove')")
    //@Log(title = "精品汇隐私条款", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(privacyPolicyService.deletePrivacyPolicyByIds(ids));
    }
}
